package com.hitqz.robot.biz.flow.component.agv;

import cn.hutool.core.date.DateUtil;
import com.hitqz.robot.biz.flow.util.LiteFlowUtil;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;

import java.util.Date;
import java.util.concurrent.CompletableFuture;

/**
 * @author xupkun
 * @date 2025/2/25
 */
@Slf4j
@LiteflowComponent(value = "LeaveLTK", name = "[轮对/轮轴]离开立体库-通知")
@AllArgsConstructor
public class LeaveLTK extends NodeComponent {

    private final RestTemplate restTemplate;

    @Override
    public void process() throws Exception {
        try {
            LiteFlowUtil.checkInterruptFlag();
            CompletableFuture.runAsync(()-> {
                String uri = "http://192.10.13.20:9999/lzms/ldltkAgvOutAck?wcsj=123&wczt=1";
                //String uri = "http://127.0.0.1:9999/admin/km/agv/call/sbbh=123&sbbh_wz=123";
                uri = uri.replace("123", DateUtil.format(new Date(),  "yyyy-MM-dd HH:mm:ss"));
                log.info("确认离开立体库的请求是:" + uri);
                String result = restTemplate.postForObject(
                        uri, "", String.class);
                log.info("确认可以立体库的请求结果是:" + result);
            });

        } catch (Exception e) {
            log.info("请求进入立体库:" + e.getMessage());
        }

    }


}
